package cn.edu.csust.cvs.management.repository;

import cn.edu.csust.cvs.management.repository.entity.VideoClipEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Auther: snail
 * @Date: 2021/1/22 00:30
 * @Description: 视频片段数据访问对象
 */
@Repository
public interface VideoClipRepository extends JpaRepository<VideoClipEntity, Integer> {

    /**
     * 查询视频片段
     * @param videoId
     * @return
     */
    List<VideoClipEntity> findByVideoIdOrderByStartTime(Integer videoId);

    /**
     * 批量查询视频片段列表
     * @param ids
     * @return
     */
    List<VideoClipEntity> findByIdIn(List<Integer> ids);

    /**
     * 清除视频片段数据
     * @param videoId
     * @return
     */
    @Modifying
    @Transactional
    void deleteByVideoId(Integer videoId);


    Page<VideoClipEntity> findAll(Specification<VideoClipEntity> spec, Pageable pageable);
}
